package com.lc.luzhengtang.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.lc.luzhengtang.R;
import com.lc.luzhengtang.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/6/15.
 */

public class CommenWebActivity extends BaseActivity{



    @BindView(R.id.regist_web_wv)
    WebView registWebWv;
    @BindView(R.id.img_news)
    ImageView imgNews;
    @BindView(R.id.text_submit)
    TextView textSubmit;
    @BindView(R.id.text_title)
    TextView textTitle;

    String flag;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_indexweb);
        ButterKnife.bind(this);
        flag=getIntent().getStringExtra("flags");
        if (flag.equals("1")){
            textTitle.setText("查看帮助");
        }

        // 支持js
        registWebWv.getSettings().setJavaScriptEnabled(true);
        registWebWv.setWebChromeClient(new WebChromeClient());
        registWebWv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

        // 缩放
        registWebWv.getSettings().setSupportZoom(true);
        registWebWv.getSettings().setBuiltInZoomControls(false);

        registWebWv.addJavascriptInterface(this, "android");

        registWebWv.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {

                registWebWv.loadUrl("javascript:getvalue()");

                super.onPageFinished(view, url);
            }

        });

        String flag = getIntent().getStringExtra("flag");

     /*   if (flag.equals("2")) {
            textTitle.setText("分销");
        }*/
        //textTitle.setText(getIntent().getStringExtra("title"));
        String url = getIntent().getStringExtra("url");


        if (!TextUtils.isEmpty(url)) {

            registWebWv.loadUrl(url);

        } else {
            finish();

        }
    }

    @OnClick({R.id.img_news, R.id.text_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_news:
                finish();
                break;
            case R.id.text_submit:
                break;
        }
    }


}
